home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tpsqapi1.zip / $ZZAPTMP.ZIP / SQDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-13  |  4KB  |  101 lines

  1. {$X+}
  2. (*--------------------------------------------------------------------------
  3.                   (c) copyright 1988-91 Santronics Software
  4. ----------------------------------------------------------------------------*)
  5. (*
  6.  This is a demo program for showing how to use the Squish Pascal API.
  7.  Note. This is not a perfect program.
  8. *)
  9.  
  10. Uses crt, dos, iofiles, strlib, Squish, DosDate;
  11.  
  12. Procedure ShowMenu;
  13.  begin
  14.   textcolor(White);
  15.   write('O - Open New Squish File,  <Enter> Read Mail,  E - Enter, Q - Quit > ');
  16.  end;
  17.  
  18. {$I DISPTXT.INC}
  19.  
  20. Var SqFv      :  Stream;
  21.     SqBase    : _sqbasetype;
  22.     Sqfhdr    : _sqfhdrtype;
  23.     Sqmhdr    : _sqmhdrtype;
  24.     sqname    : pathstr;
  25.     ch        : char;
  26.     nextframe : longint;
  27.     abytes    : longint;  (* actual message text bytes *)
  28.  
  29. Const
  30.     ShowKludge : Boolean = True;
  31.     ShowSeenby : Boolean = True;
  32.     ShowRaw    : Boolean = False;
  33.     msgid      : word    = 0;
  34.     Lockit     : Boolean = False; (* MultiLine? Sharing? *)
  35.  
  36. begin
  37.   nextframe := 0;
  38.   msgid     := 0;
  39.   repeat
  40.     ShowMenu;
  41.     ch := upcase(readkey);
  42.     writeln;
  43.     case ch of
  44.      #13 : Begin
  45.             if filerec(sqfv).mode = fmInOut then  (* file is open *)
  46.                begin
  47.                  if nextframe <> 0 then
  48.                     begin
  49.                        sqreadfhdr(sqfv,sqfhdr,nextframe);
  50.                        sqreadmhdr(sqfv,sqmhdr,nextframe);
  51.                        nextframe := sqfhdr.next_frame;
  52.                        inc(msgid);
  53.                        with sqmhdr do
  54.                           begin
  55.                             FromWhom := mat2str(FromWhom,SQMSG_FROM_SIZE-1);
  56.                             ToWhom   := mat2str(ToWhom,SQMSG_TO_SIZE-1);
  57.                             Subj     := mat2str(Subj,SQMSG_SUBJ_SIZE-1);
  58.                             textcolor(yellow);
  59.                             clrscr;
  60.                             writeln('FROM        : ',FromWhom);
  61.                             writeln('  TO        : ',ToWhom);
  62.                             writeln('SUBJ        : ',Subj);
  63.                             gotoxy(50,1);writeln('DATE WRITTEN: ',DosDateFormat(date_written,3));
  64.                             gotoxy(50,2);writeln('DATE ARRIVED: ',DosDateFormat(date_arrived,3));
  65.                             gotoxy(50,3);writeln('MSGID       : ',msgid,'/',sqbase.num_msg);
  66.                          end;
  67.                       Display_Text(sqfv, sqfhdr.msg_length, ShowRaw,ShowKludge,ShowSeenby,Abytes);
  68.                     end;
  69.                end else writeln('NO SQUISH FILE OPEN');
  70.            end;
  71.      'O' : Begin
  72.             if filerec(sqfv).mode = fmInOut then  (* already open *)
  73.                begin
  74.                  fclose(sqfv);
  75.                  writeln('previous file closed now');
  76.                end;
  77.              write('Enter Squish File Name (without extension): ');
  78.              readln(sqname);
  79.              if removelb(sqname) <> '' then
  80.                 begin
  81.                   if SqOpenSQD(sqname,sqfv, LOCKIT) = 0 then
  82.                      begin
  83.                        SqSetSQBSize(sqfv);
  84.                        SqReadBHdr(sqfv,sqbase);
  85.                        _SQFSIZE := sqbase.sz_sqhdr;
  86.                        nextframe := sqbase.begin_frame;
  87.                        msgid := 0;
  88.                      end
  89.                   else Writeln('ERROR OPENING FILE');
  90.                 end;
  91.            end;
  92.     end;
  93.   until ch = 'Q';
  94.  
  95.   if filerec(sqfv).mode = fmInOut then  (* already open *)
  96.      begin
  97.        fclose(sqfv);
  98.        writeln('previous file closed now');
  99.      end;
  100. end.
  101.